#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5005;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int n,a[N],ans;

map<vector<int>,bool> mp;

void dfs(vector<int> p){
	mp[p]=1;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(p[i]==p[j]) continue;
			vector<int> k=p;
			k[j]=k[i]=max(k[i],k[j]);
			if(!mp[k]) dfs(k);
		}		
	}
}

signed main(){
	freopen("after.in","r",stdin);
	freopen("after.out","w",stdout);
	n=read();
	vector<int> p;p.clear();
	for(int i=1;i<=n;i++) a[i]=read(),p.push_back(a[i]);
	dfs(p);
	cout<<mp.size();
	return 0;
}